package com.wdl.sm.webui.yang.type;

import com.nokia.taiji.yang.schema.YangType.Range;
import com.nokia.taiji.yang.schema.YangType.TypeDecimal64;
import com.nokia.taiji.yang.schema.YangType.TypeInteger;
import com.wdl.sm.webui.yang.YANGExt;

public class NumericValue extends NormalizedValue {
    String rangeLow;
    String rangeHigh;
    String rangeTips;
    int step;

    public NumericValue(TypeInteger input) {
        super(input);
        tag = "numeric";

        Range range = input.getRange();

        if (range != null) {
            rangeLow = String.valueOf(input.getRange().getMin());
            rangeHigh = String.valueOf(input.getRange().getMax());
            rangeTips = range.toString();
        } else {
            switch (type) {
            case "int8":
                rangeLow = "-128";
                rangeHigh = "127";
                break;
            case "uint8":
                rangeLow = "0";
                rangeHigh = "255";
                break;
            case "int16":
                rangeLow = "-32768";
                rangeHigh = "32767";
                break;
            case "uint16":
                rangeLow = "0";
                rangeHigh = "65535";
                break;
            case "uint32":
                rangeLow = "0";
                break;
            default:
                break;
            }
        }

        String stepString = YANGExt.getExtension(input, "step");
        if (!"".equals(stepString)) {
            step = Integer.parseInt(stepString);
        }
    }
    
    public NumericValue(TypeDecimal64 input) {
        super(input);
        rangeLow = String.valueOf(input.getRange().getMin());
        rangeHigh = String.valueOf(input.getRange().getMax());
    }

    public String getRangeLow() {
        return rangeLow;
    }

    public void setRangeLow(String rangeLow) {
        this.rangeLow = rangeLow;
    }

    public String getRangeHigh() {
        return rangeHigh;
    }

    public void setRangeHigh(String rangeHigh) {
        this.rangeHigh = rangeHigh;
    }
}